package com.zlll.winner.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zlll.winner.business.service.advertising.IAdvertisingPublishService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("api/advertising")
@RestController
public class AdvertisingController {

    @Reference(version = "${dubbo.consumer.version}")
    private IAdvertisingPublishService advertisingPublishService;

    /**
     * 前端获取普通广告位信息
     * @param data type 1 首页 2 论坛
     * @return
     */
    @PostMapping("/search")
    public Object search(@RequestBody JSONObject data){
        Integer type = data.getInteger("type");
        String cityName = data.getString("cityName");
        return advertisingPublishService.search(cityName, type);
    }

    /**
     * 前端获取轮播广告位信息
     * @param data
     * @return
     */
    @PostMapping("/carousel")
    public Object searchCarousel(@RequestBody JSONObject data){
        Integer type = data.getInteger("type");
        String cityName = data.getString("cityName");
        return advertisingPublishService.searchCarousel(cityName,type);
    }
}
